#include "engine.h"
#include "animation.h"

#ifdef LEO_DESIGNER
void animationcontainer_t::save(file_t& f)
{
	f.write(anims.size());

	for (uint32 n=0; n<anims.size();++n)
		anims[n].save(f);
}

void animation_t::save(file_t& f)
{
	f.write(length);
	f.write(timescale);
	f.write(name);
	f.write(tracks.size());
	for (uint32 n=0; n<tracks.size();++n)
		tracks[n].save(f);
}

void animtrack_t::save(file_t& f)
{
	f.write(node_index);

	f.write(positions.size());
	f.write(&positions[0],positions.size()*sizeof(float3));

	f.write(scales.size());
	f.write(&scales[0],scales.size()*sizeof(float3));

	f.write(rotations.size());
	f.write(&rotations[0],rotations.size()*sizeof(float4));
}
#endif




void animationcontainer_t::load(file_t& f)
{
	uint32 animnum;
	f.read(animnum);

	anims.resize(animnum);
	for (uint32 n=0; n<anims.size();++n)
		anims[n].load(f);
}

void animation_t::load(file_t& f)
{
	f.read(length);
	f.read(timescale);
	f.read(name);

	uint32 tracknum;
	f.read(tracknum);
	tracks.resize(tracknum);
	for (uint32 n=0; n<tracks.size();++n)
		tracks[n].load(f);
}

void animtrack_t::load(file_t& f)
{
	f.read(node_index);

	uint32 posnum,rotnum,scalenum;
	f.read(posnum);
	positions.resize(posnum);
	f.read(&positions[0],positions.size()*sizeof(float3));

	f.read(scalenum);
	scales.resize(scalenum);
	f.read(&scales[0],scales.size()*sizeof(float3));

	f.read(rotnum);
	rotations.resize(rotnum);
	f.read(&rotations[0],rotations.size()*sizeof(float4));
}

